﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Intex.Db.Models
{
    public class TemplateViewModel
    {
        public int Id { get; set; }

        public string Name { get; set; }

        public string TemplateFile { get; set; }

        public int ItemType { get; set; } 

        public string Value { get; set; }

        public int Rank { get; set; }

        public static readonly string QUERYSQL = "select it.ItemTemplateId as Id, it.ItemTemplateName as Name,it.ItemTemplateFile as TemplateFile,t.ItemTypeId as ItemType,its.Value as Value,t.Rank as Rank from ItemTemplate it inner join ItemTemplateValue its on it.ItemTemplateId=its.ItemTemplateId inner join ItemType t on its.ItemTypeId = t.ItemTypeId where it.ItemTemplateId in ({0})";

        public static readonly string QUERYALL = "select it.ItemTemplateId as Id, it.ItemTemplateName as Name,it.ItemTemplateFile as TemplateFile,t.ItemTypeId as ItemType,its.Value as Value,t.Rank as Rank from ItemTemplate it inner join ItemTemplateValue its on it.ItemTemplateId=its.ItemTemplateId inner join ItemType t on its.ItemTypeId = t.ItemTypeId where it.ItemTemplateName in ({0})";

    }

    public class TemplateJoinItemModel
    {
        public int Id { get; set; }

        public string Name { get; set; }

        public static readonly string QuerySqlForDisplay = "select max(ItemTemplateId) as Id,ItemTemplateName as Name from ItemTemplate group by ItemTemplateName having ItemTemplateName in({0})";

        public static readonly string QuerySqlForPrint = "select ItemTemplateId as Id,ItemTemplateName as Name from ItemTemplate where ItemTemplateName in ({0}) order by ItemTemplateName";
    }

    public class ItemViewModel
    {
        public int ItemId { get; set; }

        public DateTime CreatedDate
        {
            get
            {
                return DateTime.Parse(AddedDate);
            }
        }

        public string AddedDate { get; set; }

        public string Name { get; set; }

        public string Value { get; set; }

        public int ItemType { get; set; }

        public int PrintStatus { get; set; }

        public string ItemPrintStatus { get; set; }

        public static readonly string QUERYSQL = "select im.ItemId as ItemId, im.Name as Name,iv.Value as Value,iv.ItemTypeId as ItemType,im.CreatedDate as AddedDate, substr('未打印已打印', im.ItemTemplateId*3+1,3) as ItemPrintStatus, im.ItemTemplateId as PrintStatus from Item im inner join ItemValue iv on im.ItemId=iv.ItemId and iv.ItemTypeId in ({1}) where {0}";
    }
}
 